package com.cqfae.deploycentral.app.web.enums;

import com.cqfae.deploycentral.app.base.BaseConstantCode;

public enum ProgressColorEnum {

    PROGRESS_COLOR_START(BaseConstantCode.DEPLOY_STATUS_WAITING, ColorEnum.GREEN.getColor()),
    PROGRESS_COLOR_GIT_FAIL(BaseConstantCode.JENKINS_STATUS_GIT_FAIL, ColorEnum.RED.getColor()),
    PROGRESS_COLOR_GIT_OK(BaseConstantCode.JENKINS_STATUS_GIT_OK, ColorEnum.BLUE.getColor()),
    PROGRESS_COLOR_BUILD_FAIL(BaseConstantCode.JENKINS_STATUS_BUILD_FAIL, ColorEnum.RED.getColor()),
    PROGRESS_COLOR_BUILD_OK(BaseConstantCode.JENKINS_STATUS_BUILD_OK, ColorEnum.BLUE.getColor()),
    PROGRESS_COLOR_INPUT_FAIL(BaseConstantCode.JENKINS_STATUS_INPUT_FAIL, ColorEnum.RED.getColor()),
    PROGRESS_COLOR_INPUT_OK(BaseConstantCode.JENKINS_STATUS_INPUT_OK, ColorEnum.BLUE.getColor()),
    PROGRESS_COLOR_OUTPUT_FAIL(BaseConstantCode.JENKINS_STATUS_OUTPUT_FAIL, ColorEnum.RED.getColor()),
    PROGRESS_COLOR_OUTPUT_OK(BaseConstantCode.JENKINS_STATUS_OUTPUT_OK, ColorEnum.BLUE.getColor()),
    PROGRESS_COLOR_DEPLOY_FAIL(BaseConstantCode.JENKINS_STATUS_DEPLOY_FAIL, ColorEnum.RED.getColor()),
    PROGRESS_COLOR_DEPLOY_OK(BaseConstantCode.JENKINS_STATUS_DEPLOY_OK, ColorEnum.BLUE.getColor()),
    PROGRESS_COLOR_CHECK_FAIL(BaseConstantCode.JENKINS_STATUS_CHECK_FAIL, ColorEnum.RED.getColor()),
    PROGRESS_COLOR_CHECK_OK(BaseConstantCode.JENKINS_STATUS_CHECK_OK, ColorEnum.GREEN.getColor());

    private Integer status;

    private String color;

    ProgressColorEnum(Integer status, String color) {
        this.status = status;
        this.color = color;
    }

    public static String value(Integer status) {
        String color;
        // 设置颜色
        if (status == null) {
            return ColorEnum.GREEN.getColor();
        }
        switch (status) {
            case BaseConstantCode.DEPLOY_STATUS_WAITING:
                color = PROGRESS_COLOR_START.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_GIT_FAIL:
                color = PROGRESS_COLOR_GIT_FAIL.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_GIT_OK:
                color = PROGRESS_COLOR_GIT_OK.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_BUILD_FAIL:
                color = PROGRESS_COLOR_BUILD_FAIL.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_BUILD_OK:
                color = PROGRESS_COLOR_BUILD_OK.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_INPUT_FAIL:
                color = PROGRESS_COLOR_INPUT_FAIL.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_INPUT_OK:
                color = PROGRESS_COLOR_INPUT_OK.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_OUTPUT_FAIL:
                color = PROGRESS_COLOR_OUTPUT_FAIL.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_OUTPUT_OK:
                color = PROGRESS_COLOR_OUTPUT_OK.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_DEPLOY_FAIL:
                color = PROGRESS_COLOR_DEPLOY_FAIL.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_DEPLOY_OK:
                color = PROGRESS_COLOR_DEPLOY_OK.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_CHECK_FAIL:
                color = PROGRESS_COLOR_CHECK_FAIL.getColor();
                break;
            case BaseConstantCode.JENKINS_STATUS_CHECK_OK:
                color = PROGRESS_COLOR_CHECK_OK.getColor();
                break;
            default:
                color = ColorEnum.GREEN.getColor();
                break;
        }
        return color;
    }

    public Integer getStatus() {
        return status;
    }

    public String getColor() {
        return color;
    }
}
